<?php

namespace Kollway\CodeGenerator;

use Illuminate\Support\ServiceProvider;

use Kollway\CodeGenerator\Commands\CodeGeneratorCommand;
use Kollway\CodeGenerator\Commands\CreateControllerCommand;
use Kollway\CodeGenerator\Commands\CreateFormViewCommand;
use Kollway\CodeGenerator\Commands\CreateListDialogCommand;
use Kollway\CodeGenerator\Commands\CreateListViewCommand;
use Kollway\CodeGenerator\Commands\CreateModelCommand;

class CodeGeneratorServiceProvider extends ServiceProvider
{
    protected $defer = true;

    public function boot()
    {
        $this->publishes([
            __DIR__.'/resources/views/code-generator' => base_path('/resources/views/code-generator'),
        ]);
        $this->loadViewsFrom(__DIR__ . '/resources/views/code-generator', 'code-generator');
    }

    public function register()
    {
        $this->app->singleton('command.cg', function ($app) {
            return new CodeGeneratorCommand();
        });
        $this->app->singleton('command.cc', function ($app) {
            return new CreateControllerCommand();
        });
        $this->app->singleton('command.cm', function ($app) {
            return new CreateModelCommand();
        });
        $this->app->singleton('command.cf', function ($app) {
            return new CreateFormViewCommand();
        });
        $this->app->singleton('command.cl', function ($app) {
            return new CreateListViewCommand();
        });
        $this->app->singleton('command.cld', function ($app) {
            return new CreateListDialogCommand();
        });

        $this->commands([
            'command.cg',
            'command.cc',
            'command.cm',
            'command.cf',
            'command.cl',
            'command.cld',
        ]);
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return [
            'command.cg',
            'command.cc',
            'command.cm',
            'command.cf',
            'command.cl',
            'command.cld',
        ];
    }
}